//
//  Contact.m
//  OC04_集合(二)
//
//  Created by Hanlingyu on 16/7/7.
//  Copyright © 2016年 ltq. All rights reserved.
//

#import "Contact.h"

@implementation Contact

- (instancetype)initWithName:(NSString *)name sex:(NSString *)sex phoneNumber:(NSString *)phoneNumber address:(NSString *)address groupName:(NSString *)groupName age:(NSUInteger)age {
    self = [super init];
    if (self) {
        // 初始化方法中, 不要用set方法赋值
        _name = name;
        _sex = sex;
        _phoneNumber = phoneNumber;
        _address = address;
        _groupName = groupName;
        _age = age;
    }
    return self;
}

+ (instancetype)contactWithName:(NSString *)name sex:(NSString *)sex phoneNumber:(NSString *)phoneNumber address:(NSString *)address groupName:(NSString *)groupName age:(NSUInteger)age {
    Contact *contact = [[Contact alloc] initWithName:name sex:sex phoneNumber:phoneNumber address:address groupName:groupName age:age];
    return contact;
}

// description 是一个快速将其他类型的对象转化成字符串形式
// 可以用系统的方法, 也可以改变字符串格式
- (NSString *)description {
    return [NSString stringWithFormat:@"name = %@, @phoneNunber = %@, @sex = %@, @address = %@, @groupName = %@, @age = %ld", _name, _phoneNumber, _sex, _address, _groupName, _age];
}

- (void)showContact {
    NSLog(@"%@", self);
}

@end
